package com.magold.skill;

import org.andengine.entity.scene.Scene;

import com.magold.touch.IPinchZoomDetector;
import com.magold.touch.IPinchZoomDetector.IPinchZoomListener;

public class SprintSkillTouchListener implements IPinchZoomListener {
	private SprintSkill mSkill;
	
	public SprintSkillTouchListener(SprintSkill pSkill) {
		mSkill = pSkill;
	}
	
	@Override
	public void onPinchZoomStarted(Scene pScene, IPinchZoomDetector pDetector) {
	}

	@Override
	public void onPinchZoom(Scene pScene, IPinchZoomDetector pDetector) {
	}

	@Override
	public void onPinchZoomFinished(Scene pScene, IPinchZoomDetector pDetector) {
		float zoomFactor = pDetector.getZoomFactor();
		float initDistance = pDetector.getInitialDistance();
		
		if (zoomFactor < 0.75f && initDistance > 100f) {
			mSkill.launch();
		} else if (zoomFactor > 1.5f) {
			mSkill.stop();
		}
	}

}
